#define _CRT_SECURE_NO_WARNINGS   1

#include<iostream>
#include<string>
using namespace std;
int a[100000];
int front;
int back;
int main()
{
	int k = 0;
	int x;
	int n;
	cin >> n;
	while (n--)
	{
		string mov;
		cin >> mov;
		if (mov == "push")
		{
			cin >> x;
			a[k++] = x;
		}
		if (mov == "pop")
		{
			if (k == 0)
				cout << "error" << endl;
			else
			{
				cout << a[0] << endl;
				for (int i = 0; i<k - 1; i++)
				{
					a[i] = a[i + 1];
				}
				k--;
			}
		}
		if (mov == "front")
		{
			if (k == 0)
				cout << "error" << endl;
			else
				cout << a[0] << endl;
		}
	}
}

